I'm trying to do some CRUD operations and I want to set the models properties by iterating over a values array using the writeAttribute method but i get this error message everytime: PHP Fatal error: Call to undefined method Phalcon\Mvc\Model\Resultset\Simple::writeAttribute()
anyone sees the fault?
public function editAction($id){
$c = Countries::findById($id);
$arr = $this->request->getRawBody();
$arr = json_decode($arr, true);foreach($arr as $k => $v ){ $c->writeAttribute($k, $v); }
$c->save();
}
Also, is this way secure enough? or it will misbehabe if some field in the JSON don't exist in the model?
Thanks in advance.